package Java攻略._3_流式操作._5_利用peek方法对流进行调试;

import java.util.stream.IntStream;

public class _34_使用多个peek方法 {

    public static void main(String[] args) {
        _34_使用多个peek方法 _34 = new _34_使用多个peek方法();
        int sum = _34.sumDoubleDivisbleBy3(0, 6);
        System.out.println(sum);
    }

    public int sumDoubleDivisbleBy3(int start, int end){
        return IntStream.rangeClosed(start, end)
                .peek(n -> System.out.printf("original : %d%n",n))
                .map(n -> n * 2)
                .peek(n -> System.out.printf("doubled : %d%n",n))
                .filter(n -> n % 3 == 0)
                .peek(n -> System.out.printf("filtered : %d%n",n))
                .sum();
    }
}
